#ifndef MYMUSIC_WLFFMPEG_H
#define MYMUSIC_WLFFMPEG_H

#include "../bean/WlCallJava.h"
#include "../audio/WlAudio.h"
#include "../bean/WlPlaystatus.h"
#include "../video/WlVideo.h"

extern "C"
{
#include "../thirdpart/libavformat/avformat.h"
#include "../thirdpart/libavutil/time.h"
};


class WlFFmpeg {

public:
    const char* url = NULL;
    bool supportMediacodec = false;
    int duration = 0;
    bool exit = false;

    WlPlaystatus *playstatus = NULL;
    WlAudio *audio = NULL;
    WlVideo *video = NULL;
    WlCallJava *callJava = NULL;

    pthread_t decodeThread;
    pthread_mutex_t seek_mutex;
    pthread_mutex_t init_mutex;

    AVFormatContext *pFormatCtx = NULL;
    const AVBitStreamFilter *bsFilter = NULL;

public:
    WlFFmpeg(WlPlaystatus *playstatus, WlCallJava *callJava, const char *url);
    ~WlFFmpeg();
    /**创建解码线程*/
    void parpared();
    /**初始化ffmpeg ，获取音频的基础信息*/
    void decodeFFmpegThread();
    /**循环从地址中读取帧数据*/
    void start();
    void pause();
    void resume();
    void release();
    void seek(int64_t secds);
    /**初始化FFmpeg 和检查FFmpeg一些配置*/
    int getCodecContext(AVCodecParameters *codecpar, AVCodecContext **avCodecContext);
};


#endif //MYMUSIC_WLFFMPEG_H
